import request from "../utils/request.js";


export const getShceduleListQueryService = (params) => {
    
  return request.get("/air/user/flightSchedule/page", {params:params});
};

export const getAirportListService = () => {
  return request.get("/air/user/airport");
};

export const getAllShceduleListService= () => {
  return request.get("/air/user/flightSchedule/all");
}

export const getTicketQueryListService = (params) => {
  return request.get("/air/user/ticket/page", {params:params});
}

export const createOrderService = (ticketIds) => {
  const formData = new FormData();
  ticketIds.forEach(id => formData.append('ticketIds', id));
  
  return request.post("/air/user/order/create", formData);
}

export const getTicketByIdService = (id) => {

  return request.get(`/air/user/ticket/getTicketById/${id}`);
}

export const getOrderByStatusService = (params) => {

  return request.get(`/air/user/order/getByStatus`, {params:params});
}

export const getOrderDetailByOrderIdService = (orderId) => {

  return request.get(`/air/user/order/getByOrderId/${orderId}`);
}

export const getDiscountByPointService = (orderId) => {

  let params = new URLSearchParams();
  params.append('orderId', orderId);

  return request.get("/air/user/discount/getByPoint", {params:params});

}

export const getMemberInfoService = () => {
  return request.get("/air/user/member");
}

export const registerMemberService = () => {
  return request.post("/air/user/member");
}

export const createPaymentService = (orderId) => {
  let params = new URLSearchParams();
  params.append('orderId', orderId);
  return request.get("/air/user/payment/createPayment", {params:params});
}

export const confirmOrderService = (params) => {

  return request.get("/air/user/order/confirmOrder", {params:params});
}

export const modifyOrderService = (params) => {

  return request.get("/air/user/order/modify", {params:params});
}

export const cancelOrderService = (params) => {

  return request.get("/air/user/order/cancel", {params:params});
}